The Book of Recursion

The Book of Recursion

  • Downloads:4968
  • Type:Epub+TxT+PDF+Mobi
  • Create Date:2022-09-14 09:19:46
  • Update Date:2025-09-07
  • Status:finish
  • Author:Al Sweigart
  • ISBN:1718502028
  • Environment:PC/Android/iPhone/iPad/Kindle

Summary

An accessible yet rigorous crash course on recursive programming using Python and JavaScript examples。

Recursion, and recursive algorithms, have a reputation for being intimidating。 They're seen as an advanced computer science topic often brought up in coding interviews。 Moreover, coders often perceive the use of a recursive algorithm as a sophisticated solution that only true programmers can produce。 But there's nothing magical about recursion。 Its fearsome reputation is more a product of poor teaching than of the complexity of recursion itself。

This book teaches the basics of recursion, exposes the ways it's often poorly taught, and clarifies the fundamental principles behind all recursive algorithms。 It is project-based, containing complete, runnable programs in both Python and JavaScript, and covers several common recursive algorithms for tasks like calculating factorials, producing numbers in the Fibonacci sequence, tree traversal, maze solving, binary search, quicksort and merge sort, Karatsuba multiplication, permutations and combinations, and solving the eight queens problem。

The book also explains tail call optimization and memoization, concepts often employed to produce effective recursive algorithms, and the call stack, which is a critical part of how recursive functions work but is almost never explicitly pointed out in lessons on recursion。 The last chapter, on fractals, culminates with examples of the beautiful fractal shapes recursion can produce。

Download

Reviews

Mark A

I thoroughly enjoyed working through the code samples accompanied by Al's clear and understandable explanations。 There are gems of advice sprinkled throughout the entire book。The first couple of chapters provides a very clear explanation of recursion and a good comparison of recursion vs。 iteration。 Understanding is furthered by knowing any recursive algorithm can be performed iteratively using a loop and a stack。 Guidance is provided about when and when not to use recursion, and what three feat I thoroughly enjoyed working through the code samples accompanied by Al's clear and understandable explanations。 There are gems of advice sprinkled throughout the entire book。The first couple of chapters provides a very clear explanation of recursion and a good comparison of recursion vs。 iteration。 Understanding is furthered by knowing any recursive algorithm can be performed iteratively using a loop and a stack。 Guidance is provided about when and when not to use recursion, and what three features of a programming problem, when pres­ent, make it especially suitable to a recursive approach。Three key questions are answered for each recursive code sample: What is the base case? What argument is passed to the recursive function call? How does this argument become closer to the base case?Other parts I thoroughly enjoyed:- Seeing how a perfect maze can be represented by graph (DAG)- Quicksort walk-through (Perhaps the best explanation I've ever seen of this classic algorithm。)- Karatsuba Multiplication algorithm and also the supporting math- Introductory set theory refresher- What it means for a function to be "pure"- Memoization and why only pure functions should be memoized- How tail call optimization worksLarger projects follow that provide more opportunities to work through code and see how recursion can be used to succinctly and elegantly implement solutions。 I had fun playing with the Sliding-Tile Solver。 。。。more

Adnan Kılıç

Recursion is one of the essential subjects in computer science。 Usually, it does not guarantee a more efficient solution, but how you approach the problem with recursion will be helpful in the learning process。 In this book, Al Sweigart explains the concept of recursion starting in such a good way that you first learn the basics and how to solve any problem using recursion。 Then several projects help the reader to grasp it completely。 Reading the author's other books, such as 'Automate The Borin Recursion is one of the essential subjects in computer science。 Usually, it does not guarantee a more efficient solution, but how you approach the problem with recursion will be helpful in the learning process。 In this book, Al Sweigart explains the concept of recursion starting in such a good way that you first learn the basics and how to solve any problem using recursion。 Then several projects help the reader to grasp it completely。 Reading the author's other books, such as 'Automate The Boring Stuff With Python' would be beneficial in case reader lacks the basics of programming because they should be able to understand the code pieces and have no problem with the fundamentals。 。。。more

Mark Soohoo

I encourage folks learning programming to first buy Al Sweigart’s book, “Automate the Boring Stuff with Python”。 That book teaches you Python from the beginning and assumes no previous knowledge。 The book used in conjunction with his video course on Udemy, similarly named “Automate the Boring Stuff with Python”, are a great way to start learning Python。His latest book, "The Recursive Book of Recursion", takes the reader into the more advanced subject of recursion。 Topics include the concepts of I encourage folks learning programming to first buy Al Sweigart’s book, “Automate the Boring Stuff with Python”。 That book teaches you Python from the beginning and assumes no previous knowledge。 The book used in conjunction with his video course on Udemy, similarly named “Automate the Boring Stuff with Python”, are a great way to start learning Python。His latest book, "The Recursive Book of Recursion", takes the reader into the more advanced subject of recursion。 Topics include the concepts of the stack, pushing in and popping out of the stack, and stack overflow。 Recursion is compared to iteration, and examples are shown where both approaches are shown and critiqued。 Cases where recursion is advantageous are presented with illustrations to enhance one’s comprehension。 While not a beginner’s book, it is a good read to fill in a sufficiently complex subject。 Copious Python and JavaScript recursion code are provided。 Some fun and cool demonstrations of recursion make use of turtle graphics。 Going forward, this will be my ‘go-to’ reference for recursion。 Thank you, Al Sweigart!Here’s a breakdown of what’s included (from the book):Introduction - Covers how to set up Python and JavaScript on your computer to follow along with the code examples in the rest of the book。Part 1: Understanding RecursionChapter 1: What is Recursion? - Explains recursion and how it is the natural result of the way programming languages implement functions and function calls。 This chapter also argues that recursion isn’t nearly the elegant, mystical concept many claim it is。Chapter 2: Recursion vs。 Iteration – Dives into the differences (and many similarities) between recursive and iterative techniques。Chapter 3: Classic Recursion Algorithms – Covers famous recursive programs such as the Tower of Hanoi, the flood fill algorithm, and others。Chapter 4: Backtracking and Tree Traversal Algorithms – Discusses a problem for which recursion is particularly suited: traversing tree data structures, such as when solving mazes and navigating a directory。Chapter 5: Divide-and-Conquer Algorithms – Discusses how recursion is useful for splitting large problems into smaller subproblems and covers several common divide-and-conquer algorithms。Chapter 6: Permutations and Combinations – Covers recursive algorithms involving ordering and matching, as well as the common programming problems to which these techniques are applied。Chapter 7: Memoization and Dynamic Programming – Explains some simple tricks to improve code efficiency when applying recursion in the real world。Chapter 8: Tail Call Optimization – Covers tail call optimization, a common technique used to improve the performance of recursive algorithms, and how it works。Chapter 9: Drawing Fractals – Tours the intriguing art that can be programmatically produced by recursive algorithms。 This chapter makes use of turtle graphics for generating its images。Part 2: ProjectsChapter 10: File Finder – Covers a project that searches through the files on your computer according to custom search parameters you provide。Chapter 11: Maze Generator – Covers a project that automatically generates mazes of any size using the recursive backtracker algorithm。Chapter 12: Sliding-Tile Solver – Covers a project that solves sliding-tile puzzles, also called 15-puzzles。Chapter 13: Fractal Art Maker – Explore a project that can produce custom fractal art of your own design。Chapter 14: Droste Maker – Explores a project that produces recursive, picture-in-picture images using the Pillow image-manipulation moduleFinally, I would also recommend another one of his earlier books, “Cracking Codes with Python”。 This is an excellent book on using Python to encrypt, decrypt, and cracking various encryption algorithms。 。。。more

Rakesh

Amazing book to learn recursion and few other concepts of Python and JavaScript ! Highly recommended

Jared

As a full-stack developer in the LIS (Library and Information Science) field, Al's work has always been an important cornerstone in my coding education。 Data and Systems librarians are often self-taught, and I am no exception。 "Automate the Boring Stuff with Python" was my Bible as I took my first steps into the field and I always recommend it to anyone who wants to follow in similar footsteps。 This new title has its own place in my journey: demystifying recursion - a concept that is largely glo As a full-stack developer in the LIS (Library and Information Science) field, Al's work has always been an important cornerstone in my coding education。 Data and Systems librarians are often self-taught, and I am no exception。 "Automate the Boring Stuff with Python" was my Bible as I took my first steps into the field and I always recommend it to anyone who wants to follow in similar footsteps。 This new title has its own place in my journey: demystifying recursion - a concept that is largely glossed over in any coding classes or bootcamps。 Al handles this task with ease, thoroughly covering the gamut with his trademark accessible language, clear examples, and concise writing。 For real, there's no fat to trim in this title! The result is a surprisingly easy and enjoyable read; I recommend it to anyone who wants to clear up the mystery of recursion for themselves。 Don't worry about getting lost in the sauce; if you know the basics of Python or JavaScript, you'll have no problem following along。Note: I am writing this review based on a review copy provided by the author。 That said, I am purchasing a copy for myself because I enjoyed it so much。 。。。more

Andrew Levenson

Disclaimer: Based on a review copy provided by the author。Despite what the cutesy cover and title might have you believe, this is not a love letter to recursion, but rather a measured and heavily qualified exploration of the subject。 You're not going to read this and start applying recursion everywhere, because the book is careful to show the bad with the good, but you will come away with a better appreciation of the technique and perhaps a new way of thinking about things。If you're familiar wit Disclaimer: Based on a review copy provided by the author。Despite what the cutesy cover and title might have you believe, this is not a love letter to recursion, but rather a measured and heavily qualified exploration of the subject。 You're not going to read this and start applying recursion everywhere, because the book is careful to show the bad with the good, but you will come away with a better appreciation of the technique and perhaps a new way of thinking about things。If you're familiar with Al's other books, you know what you're getting here: a friendly guided tour of the presumably unfamiliar。 His semi-conversational style makes it a lighter read than you'd anticipate, while still being technical enough to get the core ideas across。 。。。more